package cn.wit.summit.chwan.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import cn.wit.summit.chwan.models.dto.CommentAlllistIntentData;
import cn.wit.summit.chwan.models.dto.GameInfoDetial;
import cn.wit.summit.chwan.ui.fragment.CommentAllListFragment;
import cn.wit.summit.chwan.ui.fragment.DetailFragment;
import cn.wit.summit.chwan.ui.fragment.DownlodingGamesFragment;
import cn.wit.summit.chwan.ui.fragment.GameDetialOthergameFragment;
import cn.wit.summit.chwan.ui.fragment.PersonalFragment;
import cn.wit.summit.chwan.ui.fragment.RecommendFragment;
import cn.wit.summit.chwan.utils.LogUtils;

public class DetialPagerAdapter extends BaseFragmentPagerAdapter {
    private List<String> lrcs = new ArrayList<>();
    private GameInfoDetial modleFourBean;

    public DetialPagerAdapter(FragmentManager fm, GameInfoDetial modleFourBean) {
        super(fm);
        this.modleFourBean = modleFourBean;
    }

    public void addDatas(List<String> lrcs) {
        this.lrcs.addAll(lrcs);
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment;
        LogUtils.e("intentFragment getitem");
//        switch (position) {
//            case 0:
//                fragment = DetailFragment.newInstance(modleFourBean);
//                break;
//            case 1:
//                CommentAlllistIntentData intentData = new CommentAlllistIntentData();
//                intentData.setGameId(modleFourBean.getGame_id());
//                intentData.setPackageName(modleFourBean.getGame_package_name());
//                intentData.setGameType(modleFourBean.getGame_startup_num() + "");
//                intentData.setGameIsStart(1);
//                intentData.setSgcSwitch(0);
//                intentData.setBespeakSwitch(0);
//                intentData.setCommentScoreSwitch("");
//                fragment = CommentAllListFragment.newInstance(intentData);
//                break;
//            case 2:
//                fragment = GameDetialOthergameFragment.newInstance(modleFourBean.getGame_id());
//                break;
//            default:
//                fragment = DetailFragment.newInstance(modleFourBean);
//                break;
//        }
        fragment=DownlodingGamesFragment.newInstance(1);
        return fragment;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        LogUtils.e("intentFragment getpageTitle");
        return lrcs.get(position);
    }
    //除了给定位置，其他位置的Fragment进行刷新
    public void notifyChangeWithoutPosition(int position) {
        String valueP = tags.valueAt(position);
        tags.clear();
        tags.put(position, valueP);
        notifyDataSetChanged();
    }


    @Override
    public int getCount() {
        return lrcs.size();
    }
}
